import Vue from "vue";

import VueRouter from "vue-router";

Vue.use(VueRouter);

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default function createRouter() {
  return new VueRouter({
    mode: "history",
    base: "/",
    routes: [
      {
        path: "/",
        redirect: "/index",
        component: () => import("../view/index.vue"), //pagePath('index.vue')
      },
      {
        path: "/index",
        component: () => import("../view/index.vue"),
      },
      {
        path: "/books",
        component: () => import("../view/books.vue"),
      },
      {
        path: "/myself",
        component: () => import("../view/myself.vue"),
      },
      {
        path: "*",
        component: () => import("../view/notfound.vue"),
      },
    ],
  });
}
